*Raymond RAP replication do file

*Table 1 - perceptions of whether party places third (actual voters)
*2006
tab plib3 if lib_vote==1 & libthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 
tab pcons3 if cons_vote==1 & consthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 
tab pndp3 if ndp_vote==1 & ndpthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 
tab pgreen3 if green_vote==1 & greenthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 

*2008
tab plib3 if lib_vote==1 & libthird==1 & ponly1==0 & qc==0 & year==2008 [aweight = weight ] 
tab pcons3 if cons_vote==1 & consthird==1 & ponly1==0 & qc==0 & year==2008 [aweight = weight ] 
tab pndp3 if ndp_vote==1 & ndpthird==1 & ponly1==0 & qc==0 & year==2008 [aweight = weight ] 
tab pgreen3 if green_vote==1 & greenthird==1 & ponly1==0 & year==2008 & qc==0 [aweight = weight ] 

*2011
tab plib3 if lib_vote==1 & libthird==1 & ponly1==0 & qc==0 & year==2011 [aweight = weight ] 
tab pcons3 if cons_vote==1 & consthird==1 & ponly1==0 & qc==0 & year==2011 [aweight = weight ] 
tab pndp3 if ndp_vote==1 & ndpthird==1 & ponly1==0 & qc==0 & year==2011 [aweight = weight ] 
tab pgreen3 if green_vote==1 & greenthird==1 & ponly1==0 & year==2011 & qc==0 [aweight = weight ] 


*Table 2/Figure 1
*Models of Perceptions using vote choices

*Model 1
logit plib3 i.lib_vote like101 like201 like301 like501 c.competitiveness12 c.libratio23 i.y2008 i.y2011 if libthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 1, upper left panel
margins , at(libratio23=(0(.1)1) lib_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.51 like201=.48 like301=.50 like501=.49 ) 
marginsplot , yline(0.5) addplot(hist libratio23 if libthird==1 , percent yaxis(2)) name(f1p1)

*percentage of third-party vs. other-party voters correctly perceiving the party placing third in the district
margins lib_vote , at(libratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.51 like201=.48 like301=.50 like501=.49 ) 


*Model 2
logit pcons3 i.cons_vote like101 like201 like301 like501 c.competitiveness12 c.consratio23 i.y2008 i.y2011 if consthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 1, upper right panel
margins , at(consratio23=(0(.1)1) cons_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.51 like301=.49 like501=.48 )
marginsplot , yline(0.5) addplot(hist consratio23 if consthird==1 , percent yaxis(2)) name(f1p2)

*percentage of third-party vs. other-party voters correctly perceiving the party placing third in the district
margins cons_vote , at(consratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.51 like301=.49 like501=.48 )


*Model 3
logit pndp3 i.ndp_vote like101 like201 like301 like501 c.competitiveness12 c.ndpratio23 i.y2008 i.y2011 if ndpthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 1, lower left panel
margins , at(ndpratio23=(0(.1)1) ndp_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.48 like301=.51 like501=.49 )
marginsplot , yline(0.5) addplot(hist ndpratio23 if ndpthird==1 , percent yaxis(2)) name(f1p3)

*percentage of third-party vs. other-party voters correctly perceiving the party placing third in the district
margins ndp_vote , at(ndpratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.48 like301=.51 like501=.49 )


*Model 4
logit pgreen3 i.green_vote like101 like201 like301 like501 c.competitiveness12 c.greenratio23 i.y2008 i.y2011 if greenthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 1, lower right panel
margins , at(greenratio23=(0(.1)1) green_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.49 like201=.48 like301=.50 like501=.51 )
marginsplot , yline(0.5) addplot(hist greenratio23 if greenthird==1 , percent yaxis(2)) name(f1p4)

*percentage of third-party vs. other-party voters correctly perceiving the party placing third in the district
margins green_vote , at(greenratio23=0.5 competitiveness12=.10 y2008=0 y2011=0 like101=.49 like201=.48 like301=.50 like501=.51 )

graph combine f1p1 f1p2 f1p3 f1p4


*Table 3 - perceptions of whether party places third (intended voters)
*2006
tab plib3 if ilib_vote==1 & libthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 
tab pcons3 if icons_vote==1 & consthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 
tab pndp3 if indp_vote==1 & ndpthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 
tab pgreen3 if igreen_vote==1 & greenthird==1 & ponly1==0 & qc==0 & year==2006 [aweight = weight ] 

*2008
tab plib3 if ilib_vote==1 & libthird==1 & ponly1==0 & qc==0 & year==2008 [aweight = weight ] 
tab pcons3 if icons_vote==1 & consthird==1 & ponly1==0 & qc==0 & year==2008 [aweight = weight ] 
tab pndp3 if indp_vote==1 & ndpthird==1 & ponly1==0 & qc==0 & year==2008 [aweight = weight ] 
tab pgreen3 if igreen_vote==1 & greenthird==1 & ponly1==0 & qc==0 & year==2008 [aweight = weight ] 

*2011
tab plib3 if ilib_vote==1 & libthird==1 & ponly1==0 & qc==0 & year==2011 [aweight = weight ] 
tab pcons3 if icons_vote==1 & consthird==1 & ponly1==0 & qc==0 & year==2011 [aweight = weight ] 
tab pndp3 if indp_vote==1 & ndpthird==1 & ponly1==0 & qc==0 & year==2011 [aweight = weight ] 
tab pgreen3 if igreen_vote==1 & greenthird==1 & ponly1==0 & qc==0 & year==2011 [aweight = weight ] 


*Table 4/Figure 2
*Models of Perceptions using pre-election vote intentions

*Model 1
logit plib3 i.ilib_vote like101 like201 like301 like501 c.competitiveness12 c.libratio23 i.y2008 i.y2011 if libthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 2, upper left panel
margins , at(libratio23=(0(.1)1) ilib_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.51 like201=.48 like301=.50 like501=.49 )
marginsplot , yline(0.5) addplot(hist libratio23 if libthird==1 , percent yaxis(2)) name(f2p1)

*percentage of third-party vs. other-party supporters correctly perceiving the party placing third in the district
margins ilib_vote , at(libratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.51 like201=.48 like301=.50 like501=.49 )


*Model 2
logit pcons3 i.icons_vote like101 like201 like301 like501 c.competitiveness12 c.consratio23 i.y2008 i.y2011 if consthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 2, upper right panel
margins , at(consratio23=(0(.1)1) icons_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.51 like301=.49 like501=.48 )
marginsplot , yline(0.5) addplot(hist consratio23 if consthird==1 , percent yaxis(2)) name(f2p2)

*percentage of third-party vs. other-party supporters correctly perceiving the party placing third in the district
margins icons_vote , at(consratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.51 like301=.49 like501=.48 )


*Model 3
logit pndp3 i.indp_vote like101 like201 like301 like501 c.competitiveness12 c.ndpratio23 i.y2008 i.y2011 if ndpthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 2, lower left panel
margins , at(ndpratio23=(0(.1)1) indp_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.48 like301=.51 like501=.49 )
marginsplot , yline(0.5) addplot(hist ndpratio23 if ndpthird==1 , percent yaxis(2)) name(f2p3)

*percentage of third-party vs. other-party supporters correctly perceiving the party placing third in the district
margins indp_vote , at(ndpratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.48 like301=.51 like501=.49 )


*Model 4
logit pgreen3 i.igreen_vote like101 like201 like301 like501 c.competitiveness12 c.greenratio23 i.y2008 i.y2011 if greenthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*Figure 2, lower right panel
margins , at(greenratio23=(0(.1)1) igreen_vote=1 competitiveness12=.10 y2008=0 y2011=0 like101=.49 like201=.48 like301=.50 like501=.51 )
marginsplot , yline(0.5) addplot(hist greenratio23 if greenthird==1 , percent yaxis(2)) name(f2p4)

*percentage of third-party vs. other-party supporters correctly perceiving the party placing third in the district
margins igreen_vote , at(greenratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.49 like201=.48 like301=.50 like501=.51 )

graph combine f2p1 f2p2 f2p3 f2p4


*Table 5
*Models of the Effect of Third-Place Perceptions on Third-Party Voting

*Model 1
logit lib_vote i.plib3 like101 like201 like301 like501 c.competitiveness12 c.libratio23 i.y2008 i.y2011 if libthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*predicted probabilities of voting for the third-placed party for those with/without correct perceptions of viability
margins plib3 , at(libratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.51 like201=.48 like301=.50 like501=.49 ) 


*Model 2
logit cons_vote i.pcons3 like101 like201 like301 like501 c.competitiveness12 c.consratio23 i.y2008 i.y2011 if consthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*predicted probabilities of voting for the third-placed party for those with/without correct perceptions of viability
margins pcons3 , at(consratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.51 like301=.49 like501=.48 )


*Model 3
logit ndp_vote i.pndp3 like101 like201 like301 like501 c.competitiveness12 c.ndpratio23 i.y2008 i.y2011 if ndpthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*predicted probabilities of voting for the third-placed party for those with/without correct perceptions of viability
margins pndp3 , at(ndpratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.50 like201=.48 like301=.51 like501=.49 )


*Model 4
logit green_vote i.pgreen3 like101 like201 like301 like501 c.competitiveness12 c.greenratio23 i.y2008 i.y2011 if greenthird==1 & qc==0 & top12==0 & nc1==0 & nc2==0 & nc3==0 & nc5==0 & ponly1==0 [pweight = weight ] , cluster(rid)

*predicted probabilities of voting for the third-placed party for those with/without correct perceptions of viability
margins pgreen3 , at(greenratio23=.5 competitiveness12=.10 y2008=0 y2011=0 like101=.49 like201=.48 like301=.50 like501=.51 )

